package IC.Parser;

/**
 * The error class thrown by the parser in case of a syntax error
 * this exception class contains the exception line number, a message and the token
 * that caused the error
 */
public class SyntaxError extends Exception {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7338737667117243538L;
	private int line;
	private String value;
    
	/**
	 * @param line - Line number
	 * @param value - Error message
	 */
    public SyntaxError(int line, String value){
    	super();
    	this.line = line;
    	this.value = value;
    }

    
    /**
     * returns a string representation for the error with line number, message and the token that
     * caused the syntax error
     */
    public String toString(){
    	if (value=="END_OF_FILE_ERROR")
    	{
    		return line+": Unexpected EOF!";
    	}
    	else
    		return line+": Syntax error: at token "+value;
    }
}
